/**
 * Created by csy on 2017/11/20.
 */
var id;
var uploadList = [];
require(['jquery'],function($){
    //获取url参数
    id = $.getUrlParam("id");
    dataInit(id);

});

function dataInit(id) {
    $.ajax({
        url:'api/v1/p/mms/service/order/consume/detail',
        type:'get',
        data:{
            id:id
        },
        dataType:'json'
    })
        .done(function (result) {
            if(result.code == '200'){
                var data = result.data;
                var $firstTarget = $("#basic_info").find("span");
                var $secondTarget = $("#confirm_info").find("span");
                var $thirdTarget = $("#audit_info").find("span");
                $firstTarget.eq(0).text(data.warehouseName);
                $firstTarget.eq(1).text(data.entName);
                $firstTarget.eq(2).text(data.billAccountName);
                $firstTarget.eq(3).text(data.relEntityCode);
                $firstTarget.eq(4).text(data.tradeDt);
                $firstTarget.eq(5).text();
                $firstTarget.eq(6).text(data.currency );
                $firstTarget.eq(7).text(data.amount );
                $firstTarget.eq(8).text(data.factAmount );
                $firstTarget.eq(9).text(data.consumeReason );
                $firstTarget.eq(10).text(data.consumeReasonContent );

                var confirmeStatus = "";
                switch (data.confirmeStatus){
                    case "unconfirmed": confirmeStatus= "待确认" ;break;
                    case "confirmed": confirmeStatus=  "已确认"; break;
                    case "confirme_not_pass": confirmeStatus= "未同意";break;
                }
                $secondTarget.eq(0).text(confirmeStatus);
                $secondTarget.eq(1).text(data.confirmeReply);

                var auditStatus = "";
                switch (data.auditStatus){
                    case "unaudited": auditStatus = "待审核";break;
                    case "audited": auditStatus = "已审核";break;
                    case "audit_not_pass": auditStatus = "未通过";break;
                }
                $thirdTarget.eq(0).text(auditStatus);
                $thirdTarget.eq(1).text(data.auditReply);
            }else{
                alert(result.message);
            }
        });
}
function ajaxRequestMethod(data,url,refresh) {
    $.ajax({
        contentType: "application/json; charset=utf-8",
        data:JSON.stringify(data),
        type:"post",
        url:url,
        success:function (result) {
            if(result.code==200){
                if(!refresh) {
                    dataInit(ticketId);
                }
            }else {
                $alert(result.message);
            }
        },
        error:function () {
            console.log(url+" error")
        }
    });
}

